/* eslint-disable no-console */
import {
  post,
  ajaxSetup,
} from "jquery"
import * as interfaces from './Interfaces.json'
import Tracker from './Tracker.js';

function csrfSafeMethod(method) {
  // these HTTP methods do not require CSRF protection
  return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
}

// 添加csrf 验证
// 添加日志
ajaxSetup({
  beforeSend: function (xhr, settings) {
    if (!csrfSafeMethod(settings.type) && !this.crossDomain) {
      let arr = document.cookie.split(';')
      for (let v in arr) {
        let to = arr[v].split('=');
        if (to[0].replace(/\s+/g, "") === "csrfToken") {
          xhr.setRequestHeader('x-csrf-token', to[1].replace(/\s+/g, ""));
        }
      }
    }
  },
  complete: function (xhr) {
    const settings = this;
    let userid = window.userid;
    if (process.env.NODE_ENV === 'production') {
      const host = 'cn-qingdao.log.aliyuncs.com';
      const project = 'htetest1';
      const logstore = 'hteschool';
      let log = new Tracker(host, project, logstore);
      if (settings.data) {
        log.push('_params_', settings.data);
        let data = settings.data.split('&')
        for (let v in data) {
          let to = data[v].split('=');
          if (to[0].replace(/\s+/g, "") === "uid") {
            log.push('_uid_', to[1]);
          }
          if (to[0].replace(/\s+/g, "") === "cid") {
            log.push('_cid_', to[1]);
          }
        }
      }
      log.push('_userid_', userid)
      log.push('_method_', settings.url);
      log.push('_error_', xhr.responseJSON && xhr.responseJSON.error);
      log.push('_msg_', xhr.responseJSON && xhr.responseJSON.msg);
      log.logger()
      if (xhr.responseJSON && xhr.responseJSON.msg === 'offline') {
        window.location.href = '/school.html#/login'
      }
    }
  }
});
export const asynclogin = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.login, data).then(response => {
      if (response.error == 0) {
        window.userid = response.data.userid
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

export const asyncloginphonenum = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.loginphonenum, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function () {

      reject('服务器开小差了')
    })
  })
}

export const session = function () {
  return new Promise((resolve, reject) => {
    post(interfaces.online).then(response => {
      if (response.error == 0) {
        window.userid = response.data.ID
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

export const asynccreatepassword = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.createpassword, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

export const ossupload = function () {
  return new Promise((resolve, reject) => {
    post(interfaces.ossupload).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 获取yzm
export const asyncfind_getCode = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.find_getCode, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 删除学校教室
export const asyncdelclassroom = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.delclassroom, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 创建/修改学校教室
export const asynccreatclassroom = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.creatclassroom, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 删除学校角色
export const asyncdelschoolrole = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.delschoolrole, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 创建/修改学校角色
export const asynccreatschoolrole = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.creatschoolrole, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 删除机构学校
export const asyncdelschooladdress = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.delschooladdress, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 创建机构学校
export const asynccreateschooladdress = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.createschooladdress, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 获取我的教学机构
export const asyncgetschool = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.getschool, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 获取所有校区
export const asyncgetallschooladdressbysid = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.getallschooladdressbysid, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 获取所有教师
export const asyncgetallschooluserbysid = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.getallschooluserbysid, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 获取角色
export const asyncgetallschoolrolebysid = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.getallschoolrolebysid, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 获取班级
export const asyncgetallschoolclazz = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.getallschoolclazz, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}


// 创建、修改班级
export const asynccreateschoolclazz = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.createschoolclazz, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 删除班级
export const asyncdelschoolclazz = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.delschoolclazz, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 获取教室
export const asyncgetallschoolclassroom = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.getallschoolclassroom, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 获取课程
export const asyncgetallschoolcoursebysid = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.getallschoolcoursebysid, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 获取学生
export const asyncgetallschoolstudent = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.getallschoolstudent, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 修改用户
export const asyncchangeschooluser = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.changeschooluser, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 创建用户
export const asynccreateschooluser = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.createschooluser, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 删除用户
export const asyncdelschooluser = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.delschooluser, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

export const asyncgetallschoolauthtype = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.getallschoolauthtype, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

export const asyncchangeschooolrole = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.changeschooolrole, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 创建/修改学校课程
export const asynccreatschoolcourse = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.creatschoolcourse, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 删除学校课程
export const asyncdelschoolcourse = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.delschoolcourse, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 获取所有课程包
export const asyncgetallpackegekey = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.getallpackegekey, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 获取所有课程
export const asyncgetallcourse = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.getallcourse, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 获取所有课时
export const asyncgetallschoolclasshour = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.getallschoolclasshour, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 创建/修改课程
export const asynccreateschoolclasshour = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.createschoolclasshour, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 删除课时
export const asyncdelschoolclasshour = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.delschoolclasshour, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}


// 创建、修改学生
export const asynccreateschoolstudent = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.createschoolstudent, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 删除学生
export const asyncdelschoolstudent = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.delschoolstudent, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 获取所有学生报名课程
export const asyncgetallschoolstudentschoolclazz = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.getallschoolstudentschoolclazz, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 添加删除学生课堂报名
export const asyncchangeschoolstudentschoolclazz = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.changeschoolstudentschoolclazz, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 结课
export const asyncchangeschoolclazztype = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.changeschoolclazztype, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 修改学员密码
export const asyncresetstudentpassword = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.resetstudentpassword, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}


// 获取学校上课时间
export const asyncgetschoolclasstime = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.getschoolclasstime, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 修改/创建学校上课时间
export const asynccreatschoolclasstime = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.creatschoolclasstime, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 删除学校上课时间
export const asyncdelschoolclasstime = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.delschoolclasstime, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 获取学校假期设置
export const asyncgetschoolholiday = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.getschoolholiday, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 修改/创建学校假期设置
export const asynccreatschoolholiday = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.creatschoolholiday, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 删除学校假期设置
export const asyncdelschoolholiday = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.delschoolholiday, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 获取排课日程
export const asyncgetschoolclazzschedule = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.getschoolclazzschedule, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 修改/创建排课日程
export const asynccreatschoolclazzschedule = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.creatschoolclazzschedule, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 删除排课日程
export const asyncdelschoolclazzschedule = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.delschoolclazzschedule, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 停止学生课堂
export const asyncstopschoolstudentschoolclazz = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.stopschoolstudentschoolclazz, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 查询课程日志评价
export const asyncgetschoolclazzstudentcalendar = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.getschoolclazzstudentcalendar, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}


// 修改/创建签到
export const asynccreatschoolclazzstudentcalendar = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.creatschoolclazzstudentcalendar, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 删除签到
export const asyncdelschoolclazzstudentcalendar = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.delschoolclazzstudentcalendar, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 查询课后作业
export const asyncgetschoolhomework = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.getschoolhomework, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}


// 修改/创建课后作业
export const asynccreatschoolhomework = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.creatschoolhomework, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 删除课后作业
export const asyncdelschoolhomework = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.delschoolhomework, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 点评作业
export const asyncchangeschoolstudenthomework = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.changeschoolstudenthomework, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 经营概况
export const asyncgetbusinessprofile = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.getbusinessprofile, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 教务报表
export const asyncgeteducationalstatements = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.geteducationalstatements, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 获取公告通知
export const asyncgetschoolannouncementpush = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.getschoolannouncementpush, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 创建/修改公告通知
export const asynccreatschoolannouncementpush = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.creatschoolannouncementpush, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 删除公告通知
export const asyncdelschoolannouncementpush = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.delschoolannouncementpush, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 微信模版推送
export const asyncmessagesend = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.messagesend, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 获取补课人员
export const asyncgetschoolclazzstudentcalendaroftype = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.getschoolclazzstudentcalendaroftype, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 获取异常课程
export const asynccheckconflictsschoolclazzschedule = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.checkconflictsschoolclazzschedule, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 获取题库组
export const asyncgetschoolitembankgroup = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.getschoolitembankgroup, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 添加修改题库组
export const asynccreateschoolitembankgroup = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.createschoolitembankgroup, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 删除题库组
export const asyncdelschoolitembankgroup = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.delschoolitembankgroup, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 通过题库组id获取答题
export const asyncgetschoolitembankbygroupid = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.getschoolitembankbygroupid, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 创建、修改答题
export const asynccreateschoolitembank = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.createschoolitembank, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 删除答题
export const asyncdelschoolitembank = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.delschoolitembank, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}

// 删除答题
export const asynccreateschoolitembankreply = function (data) {
  return new Promise((resolve, reject) => {
    post(interfaces.createschoolitembankreply, data).then(response => {
      if (response.error == 0) {
        resolve(response.data)
      } else {
        reject(response.msg)
      }
    }).catch(function (error) {
      console.log(error);
      reject('服务器开小差了')
    })
  })
}
